﻿/*
 * 
 *	C# object representation of row in 'researchRepo.projects' table:
 *	
 *	Currently a simple mapping of all table columns to equivalent properties,
 *	though the class might be expanded to track appropriate relationships with other tables.
 * 
 */

namespace ResearchRepository.Models
{
	public class RRProject
	{
		public RRProject(int pID, string pName, int rootDID, int dID, int rID)
		{
			ProjId = pID;
			ProjName = pName;
			RootDirId = rootDID;
			DiscId = dID;
			ResId = rID;
		}
		public RRProject(RRProject source)
			:this(source.ProjId,
					source.ProjName,
					source.RootDirId,
					source.DiscId,
					source.ResId)
		{}
		public RRProject(System.Data.IDataRecord source)
			:this((int) source["projID"],
					(string) source["projName"],
					(int) source["rootDirID"],
					source["discID"] != System.DBNull.Value ? (int) source["discID"] : 0,	// discID may be NULL
					source["resID"] != System.DBNull.Value ? (int) source["resID"] : 0)		// resID may be NULL
		{}

		// named alias for constructor, provides handle to simulate a function pointer to constructor
		public static RRProject construct(System.Data.IDataRecord source)
		{
			return new RRProject(source);
		}

		public int ProjId { get; set; }
		public string ProjName { get; set; }
		public int RootDirId { get; set; }
		public int DiscId { get; set; }
		public int ResId { get; set; }
	}
}